package io.renren.modules.service.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.modules.service.dao.ReportIPQCDao;
import io.renren.modules.service.entity.ReportIPQCEntity;
import io.renren.modules.service.service.ReportIPQCService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

@Service
public class ReportIPQCServiceImpl extends ServiceImpl<ReportIPQCDao, ReportIPQCEntity> implements ReportIPQCService {


    @Override
    public PageUtils queryReportIPQCAll(Map<String, Object> params) {
        IPage<ReportIPQCEntity> page = this.page(
                new Query<ReportIPQCEntity>().getPage(params),
                new QueryWrapper<ReportIPQCEntity>().eq("ri_status",1).orderByDesc("create_time")
        );

        return new PageUtils(page);
    }

    @Transactional
    @Override
    public void saveOrUpdateIpqcReport(ReportIPQCEntity reportIPQCEntity) {
        this.saveOrUpdate(reportIPQCEntity);
    }

    @Override
    public ReportIPQCEntity getIpqcReport(Integer id) {

        return this.getById(id);
    }

    @Override
    public void updateIpqcReport(List<ReportIPQCEntity> reportIPQCEntityList) {

        this.updateBatchById(reportIPQCEntityList,reportIPQCEntityList.size());
    }
}
